<%@ page import="com.mlt.back.service.impl.InfoDetailServiceImpl" %>
<%@ page import="com.mlt.back.beans.InfoDetail" %>
<%@ page import="java.util.List" %>
<%@ page import="com.mlt.back.service.impl.BasicInfoServiceImpl" %>
<%@ page import="com.mlt.back.beans.BasicInfo" %>
<%@ page import="java.util.ArrayList" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%
    // 获取数据
    List<BasicInfo> basicInfos = new BasicInfoServiceImpl().list();
    List<InfoDetail> infoDetails = new InfoDetailServiceImpl().list();
    // 获取请求头
    String basicInfoId = request.getParameter("basic_info_id");
    // 判断是否为分类
    if (basicInfoId == null || basicInfoId.isEmpty()){

    }else {
        // 获取指定分类下的数据
        List<InfoDetail> temp = new ArrayList<>();
        for (InfoDetail infoDetail : infoDetails) {
            if (String.valueOf(infoDetail.getFkBasicInfoId()).equals(basicInfoId)){
                temp.add(infoDetail);
            }
        }
        infoDetails = temp;
    }
%>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
</head>

<body>
<!--分类列表-->
<div style="width: 30%;float: left;">
    <div>
        <h4>规格列表</h4>
    </div>
    <div>
        <ul>
            <%for (BasicInfo basicInfo : basicInfos) {%>
            <li><a href="info_detail_list.jsp?basic_info_id=<%=basicInfo.getBasic_info_id()%>"><%=basicInfo.getBasic_info_name()%></a></li>
            <%}%>
        </ul>
    </div>
</div>
<!--列表展示-->
<div style="width: 70%;float: left;margin-top: 50px;">
    <table id="tab01" border="1px solid #ccc" cellspacing="0" cellpadding="0">
        <thead>

        <button><a href="add_info_detail.jsp">添加选项</a></button>
        <button><a>批量删除</a></button>

        <tr>

            <th width="25px"><label><input type="checkbox"><span></span></label></th>
            <th width="80px">编号</th>
            <th width="100px">产品名称</th>
            <th width="400px">选项描述</th>
            <th width="180px">操作</th>

        </tr>
        </thead>
        <tbody style="text-align: center;">
        <%for (InfoDetail infoDetail : infoDetails) {%>
        <tr>
            <td width="25px"><label><input type="checkbox"><span></span></label></td>
            <td width="80px"><%=infoDetail.getInfoDetailId()%></td>
            <td width="250px"><%=infoDetail.getInfoDetailName()%></td>
            <td width="100px"><%=infoDetail.getInfoDetailDesc()%></td>
            <td width="100px">
                <button><a href="/mlt_war_exploded/modify_info_detail.jsp?info_detail_id=<%=infoDetail.getInfoDetailId()%>">修改</a></button>
                <button><a href="/mlt_war_exploded/infoDetail/remove?id=<%=infoDetail.getInfoDetailId()%>">删除</a></button>
            </td>
        </tr>
        <%}%>
        </tbody>
    </table>
</div>
</body>

</html>
